<template>
  <div>
    <Form :loadapi="loadapi" :loadParams="loadParams" :submitapi="submitapi" :callBack="handleSubmited" :idobject="idobject" mode="page"></Form>
  </div>
</template>

<script setup lang="ts" name="contactForm">
import Form from "@/components/common/From.vue";

import { ref, onMounted, reactive,onActivated } from "vue";
import { useRouter, useRoute } from "vue-router";
const router = useRouter();
const route = useRoute();

import { useRouterStore } from "@/stores/router";
const routerStore = useRouterStore();

interface loadParams {
  [x: string]: any; //动态添加属性
}

const loadapi = ref("");
const loadParams: loadParams = {};
const submitapi = ref("");
const idobject = route.query.idobject;

if (route.query.itemid) {
  loadParams[`${idobject}_id`] = route.query.itemid;
}

loadapi.value = route.query.itemid
  ? `${idobject}.edit.do`
  : `${idobject}.new.do`;
  
submitapi.value = route.query.itemid
  ? `${idobject}.editsave.do`
  : `${idobject}.newsave.do`;

  // newversion

function handleSubmited() {
  routerStore.mode = "reload";
  router.go(-1);
}

onActivated(() => {
  // console.log("onActivated")
  document.title = sessionStorage.getItem("stitle") || "渠道管理"
})

onMounted(() => {
  window.scrollTo(0, 0);
  document.title = sessionStorage.getItem("stitle") || "渠道管理"
});

</script>

<style scoped>
</style>